import { _decorator, Component, Label, Node, v2 } from 'cc';
import { Village } from '../entity/Village';
import { WorldController } from '../common/WorldController';
import { UIManager } from '../common/UIManager';
const { ccclass, property } = _decorator;

@ccclass('RankDetailVillage')
export class RankDetailVillage extends Component {
    @property(Label)
    villageName:Label
    @property(Label)
    people:Label
    @property(Label)
    coord:Label
    @property(Node)
    arrow:Node

    private village:Village
    start() {
        this.node.on(Node.EventType.TOUCH_END, this.onTouch, this)
    }

    setData(village:Village) {
        this.village = village

        if(village.isMainVillage){
            this.villageName.string = village.name + '(主村)'
        } else {
            this.villageName.string = village.name
        }
        
        this.people.string = village.people + ''
        this.coord.string = `(${village.x}|${village.y})`
      

    }

    onTouch(){
        WorldController.centerPos = v2(this.village.x, this.village.y)
        UIManager.instance.loadScene('world')
    }
}


